/**
 *
 * 欢迎页控制器
 * 
 */
class SplashController extends Controller {
    private splashView: SplashView;

    private static DELAY_TIME = 3000;

    public constructor() {
        super();
    }

    protected init(): void {
        super.init();
    }

    protected initListeners(): void {
        super.initListeners();
        /** 注册添加欢迎页通信指令 */
        this.addCommand(CMDEvent.OPEN_SPLASH,this.showSplash,this);

    }
    /**
     * 展示欢迎页
     */
    private showSplash(event: egret.Event) {
        this.splashView = new SplashView();
        this.splashView.addEventListener(CMDEvent.SCROLL_SPLASH,this.openQuestion,this);
        this.root.addChild(this.splashView);
        /** 开始加载问题1的资源 */
        this.dispatch(CMDEvent.LOAD_LOADING,CMDEvent.GROUP_QUESTION_1);
    }

    private openQuestion(event: egret.Event): void {
        this.splashView.top = this.splashView.bottom = NaN;
        egret.Tween.get(this.splashView).to({ y: -3000 },1200);
        this.dispatch(CMDEvent.OPEN_QUESTION,0);
    }


}
